import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;


public class DBConnection {

	 private Connection connection;
	 public Connection getConnection() {
		return connection;
	}
	public void setConnection(Connection connection) {
		this.connection = connection;
	}
	public DBConnection(){
		 try {
	            Class.forName("com.mysql.jdbc.Driver");
	            String connectionUrl = "jdbc:mysql://localhost/smartcityguide?" + "user=root&password=";
	           connection = DriverManager.getConnection(connectionUrl);
	        } catch (SQLException e) {
	            System.out.println("SQL Exception: "+ e.toString());
	        } catch (ClassNotFoundException cE) {
	            System.out.println("Class Not Found Exception: "+ cE.toString());
	        }
	 }

    public void close() {
        try {
            connection.close();
        } catch (SQLException ex) {
            Logger.getLogger(DBConnection.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
	
}
